import os

from cx_Freeze import setup, Executable

from common import constants
from common.util import Util

includes_list = Util.read_requirements()
directories = [
    ('static/conf/', 'static/conf/'),
    ('static/log/', 'static/log/')
]

# 检查目录是否存在，不存在则跳过
include_files = [(src, dest) for src, dest in directories if os.path.exists(src)]

build_exe_options = {
    "includes": includes_list,
    "include_files": include_files,
    # 指定自定义构建目录名称
    "build_exe": "build/extender"
}

setup(
    name=f"crawler_message",
    version="1.0",
    description="Crawling Message Notification Applications",
    executables=[Executable(f"{constants.MAIN_PROGRAM}.py")],
    options={
        "build_exe": build_exe_options
    }
)
